﻿<UserControl x:Class="eStream.Helpdesk.Notifier.NotificationPopup"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:tb="http://www.hardcodet.net/taskbar"
             mc:Ignorable="d" 
             x:Name="me"
             d:DesignHeight="124" d:DesignWidth="264"
             Height="128"  Width="272"
             DataContext="{Binding CurrentTicket,RelativeSource={RelativeSource Self}}"
             MouseEnter="grid_MouseEnter" MouseLeave="grid_MouseLeave"
             >
    <UserControl.Resources>
        <Storyboard x:Key="FadeIn">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiContainer" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.95"/>
                <SplineDoubleKeyFrame KeyTime="00:00:03" Value="0.95"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="HighlightCloseButton">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgClose" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.7"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FadeCloseButton">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgClose" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0.7"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="HighlightPreviousButton">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgPrevious" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.7"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FadePreviousButton">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgPrevious" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.7"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="HighlightNextButton">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgNext" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.7"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FadeNextButton">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgNext" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.7"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>        
        <Storyboard x:Key="FadeBack">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiContainer" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="FadeOut" Completed="OnFadeOutCompleted" >
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="uiContainer" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.2"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
    <UserControl.Triggers>
        <EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonShowing">
            <BeginStoryboard Storyboard="{StaticResource FadeIn}" x:Name="FadeIn_BeginStoryboard"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="imgClose">
            <BeginStoryboard Storyboard="{StaticResource HighlightCloseButton}" x:Name="HighlightCloseButton_BeginStoryboard"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="imgClose">
            <BeginStoryboard Storyboard="{StaticResource FadeCloseButton}" x:Name="FadeCloseButton_BeginStoryboard"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="imgPrevious">
            <BeginStoryboard Storyboard="{StaticResource HighlightPreviousButton}" x:Name="HighlightPreviousButton_BeginStoryboard"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="imgPrevious">
            <BeginStoryboard Storyboard="{StaticResource FadePreviousButton}" x:Name="FadePreviousButton_BeginStoryboard"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="imgNext">
            <BeginStoryboard Storyboard="{StaticResource HighlightNextButton}" x:Name="HighlightNextButton_BeginStoryboard"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="imgNext">
            <BeginStoryboard Storyboard="{StaticResource FadeNextButton}" x:Name="FadeNextButton_BeginStoryboard"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseEnter">
            <StopStoryboard BeginStoryboardName="FadeIn_BeginStoryboard"/>
            <BeginStoryboard x:Name="FadeBack_BeginStoryboard1" Storyboard="{StaticResource FadeBack}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonClosing">
            <BeginStoryboard Storyboard="{StaticResource FadeOut}" x:Name="FadeOut_BeginStoryboard"/>
        </EventTrigger>
    </UserControl.Triggers>
    <Border x:Name="uiContainer" BorderThickness="2" BorderBrush="Black" Background="White">
        <Grid Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="44" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="14" />
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" VerticalAlignment="Top">
                <Image Cursor="Hand" Source="/Images/ticket.png" ToolTip="View Ticket" MouseDown="Ticket_MouseDown" />
                <TextBlock HorizontalAlignment="Center">
                    <Run Text="{Binding CurrentTicketNumber, ElementName=me}"></Run>
                    <Run Text=" / "></Run>
                    <Run Text="{Binding LastTicketNumber, ElementName=me}"></Run>
                </TextBlock>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Image Cursor="Hand" Source="/Images/Previous.png" Opacity="0.7" ToolTip="Previous" x:Name="imgPrevious" MouseDown="imgPrevious_MouseDown" />
                    <Image Cursor="Hand" Source="/Images/Next.png" Opacity="0.7" ToolTip="Next" x:Name="imgNext" MouseDown="imgNext_MouseDown" />
                </StackPanel>
            </StackPanel>
            <StackPanel Cursor="Hand" Grid.Column="1" Margin="10,0,5,0" VerticalAlignment="Top" IsHitTestVisible="True" MouseDown="Ticket_MouseDown">
                <TextBlock Height="50" Text="{Binding Subject}" FontWeight="Bold" TextWrapping="Wrap" TextTrimming="WordEllipsis"></TextBlock>
                <TextBlock Height="65" Text="{Binding Content}" TextWrapping="Wrap" TextTrimming="WordEllipsis" />                
            </StackPanel>
            <Image Cursor="Hand" Grid.Column="2" VerticalAlignment="Top" Source="/Images/Close.png" Opacity="0.7" ToolTip="Close" x:Name="imgClose" MouseDown="imgClose_MouseDown"/>

        </Grid>
    </Border>
</UserControl>
